package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.AliCount;
import com.stylefeng.guns.modular.system.service.IAliCountService;

/**
 * 支付统计控制器
 *
 * @author fengshuonan
 * @Date 2018-10-16 15:30:37
 */
@Controller
@RequestMapping("/aliCount")
public class AliCountController extends BaseController {

    private String PREFIX = "/system/aliCount/";

    @Autowired
    private IAliCountService aliCountService;

    /**
     * 跳转到支付统计首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "aliCount.html";
    }

    /**
     * 跳转到添加支付统计
     */
    @RequestMapping("/aliCount_add")
    public String aliCountAdd() {
        return PREFIX + "aliCount_add.html";
    }

    /**
     * 跳转到修改支付统计
     */
    @RequestMapping("/aliCount_update/{aliCountId}")
    public String aliCountUpdate(@PathVariable Integer aliCountId, Model model) {
        AliCount aliCount = aliCountService.selectById(aliCountId);
        model.addAttribute("item",aliCount);
        LogObjectHolder.me().set(aliCount);
        return PREFIX + "aliCount_edit.html";
    }

    /**
     * 获取支付统计列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return aliCountService.selectList(null);
    }

    /**
     * 新增支付统计
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(AliCount aliCount) {
        aliCountService.insert(aliCount);
        return SUCCESS_TIP;
    }

    /**
     * 删除支付统计
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer aliCountId) {
        aliCountService.deleteById(aliCountId);
        return SUCCESS_TIP;
    }

    /**
     * 修改支付统计
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(AliCount aliCount) {
        aliCountService.updateById(aliCount);
        return SUCCESS_TIP;
    }

    /**
     * 支付统计详情
     */
    @RequestMapping(value = "/detail/{aliCountId}")
    @ResponseBody
    public Object detail(@PathVariable("aliCountId") Integer aliCountId) {
        return aliCountService.selectById(aliCountId);
    }
}
